//我的经验！！！！！！！！！！！！！！！
var isover=0;
var username;//用户中文名
var currentIndex=1;//页码
$().ready(function(){
    $.ajax({
        type: "post",
        datatype: "json",
        url: userurl,
        data:{"userId":id},
        success:function(data){
            username=data.Data.nick;
            aj();
        }
    });

});
//ba4d39d74ed0fdcb
var ajaxrunning="no";
function aj(){
    if(isover===0){
        ajaxrunning="yes";
        $.ajax({
            type:"get",
            datatype: "json",
            url: myexpurl+"?userId="+id+"&pageSize=15&currentIndex="+currentIndex,
            success:function(d){
                console.log(d);
                if(d.Message==="没有数据"){
                    isover=1;//没有数据了
                    $("#waiting").css("display","none");
                    $("#nonews").css("display","block");
                }else{
                    if(d.Data&&d.Data.length>0){
                        if(d.Data.length<15){
                            $("#waiting").css("display","none");
                            $("#nonews").css("display","block");
                        }

                        var num=0;
                        for(var i=0;i<d.Data.length;i++){
                            num++;
                            if(num===d.Data.length){
                                ajaxrunning="no";
                            }
                            var jname1="";
                            var reg2=/[\u4E00-\u9FA5]*/;

                            var unick1="";
                            unick1=d.Data[i].userNick;

                            var count=0;
                            if(d.Data[i].browseCount){count=d.Data[i].browseCount;}
                            //判断是否有点赞者
                            var userimg="";//保存头像代码段
                            //if(d.Data[i].userList.length>0&&d.Data[i].userList.length<10){
                            //    for(var r1=0;r1<d.Data[i].userList.length;r1++){
                            //        if(d.Data[i].userList[r1]){
                            //            console.log(d.Data[i].userList[r1].nick);
                            //            if(d.Data[i].userList[r1].userAva){
                            //                userimg+="<div><img src='http://42.62.66.198:8003/"+d.Data[i].userAva+"'/></div>";
                            //            }
                            //        }
                            //    }
                            //}else if(d.Data[i].userList.length>0&&d.Data[i].userList.length>10){
                            //    for(var r2=0;r2<10;r2++){
                            //        if(d.Data[i].userList[r2]){
                            //            console.log(d.Data[i].userList[r2].nick);
                            //            if(d.Data[i].userList[r2].userAva){
                            //                userimg+="<div><img src='http://42.62.66.198:8003/"+d.Data[i].userList[r2].userAva+"'/></div>";
                            //            }
                            //        }
                            //    }
                            //}
                            var tim=d.Data[i].cTime.match(/([0-9\-]+)/)[0];
                            if(d.Data[i].cTime){
                                tim=getDateDiff(getDateTimeStamp(d.Data[i].cTime));
                            };
                            var nimingimg="";
                            if(d.Data[i].isHideName===1){
                                nimingimg="<img class='rt' src='img/niming.png'>"
                            }
                            $("#questionlist").append("<div class='pagedlist_item shareexperience'><div class='feed_item feed_type_question'><div class='EventHeader'><span class='senduser'>"+unick1+"</span><span class='job'>·</span>"+tim+nimingimg+"</div><h2><a class='question_link' href='shareexppage.html?eid="+d.Data[i].id+"'>"+d.Data[i].title+"</a></h2><div class='upviter'>"+userimg+"</div><div class='ActionBar Question'> <div class='action_bar_inner'><div class='action_item'> <a class='ReadMoreActionItem'>浏览 "+count+"</a> </div> </div></div></div></div>")
                            //<div class='action_item'> <a class='ReadMoreActionItem'>有用 "+d.Data[i].UpCount+"</a> </div>
                        }
                    }
                    else{
                        $("#waiting").css("display","none");
                        $("#nonews").css("display","block");
                    }
                }

            }
        })
    }

}
$(window).scroll(function(){
    var mainheight=$(".home_feed").height();
    //console.log("加载区域高度："+mainheight);
    var windowheight=$(window).height();
    //console.log("窗口高度："+windowheight);
    var what=$(".home_feed").offset().top;
    var chajuli=$(".home_feed").offset().top - $(window).scrollTop();
    var cz=windowheight-mainheight+50;
    //console.log("窗口与加载差值："+cz);
    //console.log("差值"+chajuli);
    if(chajuli<cz&&ajaxrunning==="no"){
        currentIndex++;
        aj();
    }
});
//搜索
document.onkeydown=function(event){
    var e = event || window.event || arguments.callee.caller.arguments[0];
    if(e && e.keyCode==13){ // enter 键
        var word=document.getElementById("searchinput").value;
        if(word){
            if(word.match(/^\s+$/g)){
                console.log("没有填信息")
            }else{
                location.href="search.html?searchKey="+word;
            }
        }
    }
};
document.getElementById("gotosearch").onclick=function(){
    var word=document.getElementById("searchinput").value;
    if(word){
        if(word.match(/^\s+$/g)){
            console.log("没有填信息")
        }else{
            location.href="search.html?searchKey="+word;
        }
    }
};